#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

inline long long ckjread()
{
	long long s=0,w=1,ch=getchar();
	while(ch<'0'||ch>'9') ch=='-'?w=-1,ch=getchar():ch=getchar();
	while(ch>='0'&&ch<='9') s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return s*w;
}

void jynwriten(long long x)
{
	x>9?jynwriten(x/10),putchar(x%10|48):putchar(x|48);
}

struct node
{
	int type;
	int x;
	long long v;
}que[200005];

struct tmpnode
{
	long long val;
	int x,id;
}tmp[500005];

int n,q;
long long a[100005];
int tmpcnt;
int tree[500005];

inline bool cmp(tmpnode x,tmpnode y)
{
	if(x.val==y.val)
	{
		return x.x<y.x;
	}
	return x.val<y.val;
}

inline void addt(int pos,int k)
{
	for(int i=pos;i<=tmpcnt;i+=i&-i)
	{
		tree[i]+=k;
	}
}

inline int quet(int pos)
{
	int res=0;
	for(int i=pos;i>=1;i-=i&-i)
	{
		res+=tree[i];
	}
	return res;
}

int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	n=ckjread();
	q=ckjread();
	for(int i=1;i<=n;i++)
	{
		a[i]=ckjread();
		tmp[++tmpcnt].val=a[i];
		tmp[tmpcnt].x=i;
		tmp[tmpcnt].id=i;
	}
	for(int i=1;i<=q;i++)
	{
		que[i].type=ckjread();
		que[i].x=ckjread();
		if(que[i].type==1)
		{
			que[i].v=ckjread();
			tmp[++tmpcnt].val=que[i].v;
			tmp[tmpcnt].x=que[i].x;
			tmp[tmpcnt].id=n+i;
		}
	}
	sort(tmp+1,tmp+tmpcnt+1,cmp);
	for(int i=1;i<=tmpcnt;i++)
	{
		if(tmp[i].id<=n)
		{
			a[tmp[i].id]=i;
		}
		else
		{
			que[tmp[i].id-n].v=i;
		}
	}
	for(int i=1;i<=n;i++)
	{
		addt(a[i],1);
	}
	for(int i=1;i<=q;i++)
	{
		if(que[i].type==1)
		{
			addt(a[que[i].x],-1);
			a[que[i].x]=que[i].v;
			addt(a[que[i].x],1);
		}
		else
		{
			jynwriten(quet(a[que[i].x]));
			putchar('\n');
		}
	}
	return 0;
}
